import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AppointmentService } from 'src/app/service/business/appointment.service';
import { CommonService } from 'src/app/service/common/common.service';
import { MessageService } from 'src/app/service/message.service';

@Component({
  selector: 'app-appointment-li',
  templateUrl: './appointment-li.component.html',
  styleUrls: ['./appointment-li.component.scss']
})
export class AppointmentLiComponent implements OnInit {

  constructor(
    private common: CommonService,
    private appointment: AppointmentService,
    private message: MessageService,
    private router: Router
  ) { }

  cols = {
    'hallName': '营业大厅',
    'appointmentTypeName': '预约业务',
    'appointmentTimeBegin': '预约时段',
    'appointmentStateName': '状态',
    'appointmentUserName': '预约人',
    'appointmentUserTel': '预约电话',
    // '操作': '操作',
  }

  ngOnInit(): void {
    this.common.setRightInfoVisible(false)
    this.getAppointmentList()
  }
  data = []
  dataLoading = false
  pageNumber = 1
  pageSize = 10
  total = 0
  getAppointmentList(){
    this.data = []
    this.dataLoading = true
    this.appointment._getAppointmentLi(this.pageNumber, this.pageSize).subscribe({
      next: res => {
        if(res && res.resultList){
          this.data = res.resultList
          this.total = res.totalNumber
        }
        this.dataLoading = false
      },
      error: error => {
        this.message.createErrorMessage(error)
        this.dataLoading = false
      }
    })
  }

  goDetail(data: any){

  }
  add(){
    this.router.navigate(['/business/appointment'])
  }
}
